﻿package mortal.game.view.vip.panel
{
    import com.greensock.*;
    import com.greensock.easing.*;
    import com.mui.controls.*;
    import com.mui.utils.*;
    import flash.events.*;
    import mortal.game.view.common.*;

    public class VipPictureBox extends GSprite
    {
        private var _pic:GImageBitmap;
        private var _picSprite:GSprite;
        private var _tween:TweenMax;

        public function VipPictureBox()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._picSprite = UICompomentPool.getUICompoment(GSprite);
            this._picSprite.x = 112;
            this._picSprite.y = 37;
            this.addChild(this._picSprite);
            this._pic = UIFactory.gImageBitmap("", -112, -37, this._picSprite);
            this.configEventListener(MouseEvent.MOUSE_OVER, this.overHandler);
            this.configEventListener(MouseEvent.MOUSE_OUT, this.outHandler);
            this.mouseEnabled = true;
            this.mouseChildren = false;
            this.buttonMode = true;
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._pic.dispose(param1);
            this._pic = null;
            this._picSprite.dispose(param1);
            this._picSprite = null;
            if (this._tween)
            {
                this._tween.kill();
            }
            return;
        }// end function

        private function overHandler(event:MouseEvent) : void
        {
            if (this.isDisposed)
            {
                return;
            }
            if (this._tween)
            {
                this._tween.kill();
            }
            this._tween = TweenMax.to(this._picSprite, 0.5, {scaleX:1.15, scaleY:1.15, ease:Quint.easeOut});
            this.parent.setChildIndex(this, (this.parent.numChildren - 1));
            return;
        }// end function

        private function outHandler(event:MouseEvent) : void
        {
            if (this.isDisposed)
            {
                return;
            }
            if (this._tween)
            {
                this._tween.kill();
            }
            this._tween = TweenMax.to(this._picSprite, 0.5, {scaleX:1, scaleY:1, ease:Quint.easeOut});
            return;
        }// end function

        public function showOver(param1:Object = null) : void
        {
            if (this.isDisposed)
            {
                return;
            }
            if (this._tween)
            {
                this._tween.kill();
            }
            this._tween = TweenMax.to(this._picSprite, 0.2, {scaleX:1.15, scaleY:1.15, onComplete:this.onComplete});
            this.parent.setChildIndex(this, (this.parent.numChildren - 1));
            return;
        }// end function

        private function onComplete() : void
        {
            if (this._tween)
            {
                this._tween.kill();
            }
            this._tween = TweenMax.to(this._picSprite, 0.2, {scaleX:1, scaleY:1});
            return;
        }// end function

        public function killTween() : void
        {
            if (this._tween)
            {
                this._tween.kill();
                var _loc_1:int = 1;
                this._picSprite.scaleY = 1;
                this._picSprite.scaleX = _loc_1;
            }
            return;
        }// end function

        public function set data(param1:String) : void
        {
            this._pic.imgUrl = param1 + ".png";
            return;
        }// end function

    }
}
